feat(messaging/feishu): AskUserQuestion 按钮交互 + docs 同步更新#474
Merged
hrygo merged 8 commits intoMay 22, 2026
Conversation
…tion options Replace markdown bullet list with CardKit v2 `action` elements containing `copy_text` buttons. Users tap a button to copy the option label, then paste it in chat to respond. Options with descriptions show a numbered reference list above the buttons for context. Fixes hrygo#457 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ion + copy_text JSON 2.0 does not support tag:"action" interactive modules or copy_text click behavior (confirmed by official Feishu docs). Question cards now use buildV1Card which omits the schema field, defaulting to JSON 1.0 where action + copy_text buttons work correctly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Options are now always rendered as a numbered list in the markdown element, regardless of whether descriptions exist. This ensures options remain visible if the action buttons fail to render on any client. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ildV1Card
JSON 1.0 cards use "elements" at root level, not "body":{"elements":...}.
Also fix misleading "CardKit v2" comments to accurately reflect JSON 1.0 usage.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
hotplex-ai
previously approved these changes
May 22, 2026
Owner
hotplex-ai
left a comment
There was a problem hiding this comment.
审查摘要
飞书 AskUserQuestion 交互改造,3 个文件,+252/-25。
审查通过项:
buildV1Card()正确构建 JSON 1.0 卡片(无 schema/body wrapper),测试验证通过buildQuestionElements()实现完整:编号列表作为按钮 fallback(良好 UX 决策),copy_text 按钮组逻辑清晰sendQuestionRequest()从手工字符串拼接重构为声明式元素构建,代码可读性显著提升- 5 组 table-driven 测试覆盖:有/无 description、无选项、多问题、空 header、完整 round-trip
- 使用 JSON 1.0 的决策合理(action + copy_text 不支持 JSON 2.0)
亮点:
- 编号列表 fallback 确保不支持按钮的客户端仍可正常使用
t.Parallel()全覆盖- 元素构建与组装分离,便于单元测试
Fixes #457 ✓
…l docs - admin-api.md: fix cron paths /api/cron/ → /admin/cron/, add restart endpoint, add API Key User Management section (5 endpoints) - feishu-integration.md: update Q&A interaction to describe CardKit v2 copy_text buttons instead of text-only response - security-model.md: add APIKeyResolver enterprise multi-user session isolation to Layer 2 description Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
…recated soul field - admin-api.md: /api/cron/* → /admin/cron/* (7 routes, scope table, descriptions, curl example) - admin-api.md: /admin/health/ready exempted from Bearer token auth for k8s probes - configuration.md: remove per-bot soul field (removed from SlackBotConfig and FeishuBotConfig)
hotplex-ai
previously approved these changes
May 22, 2026
Owner
hotplex-ai
left a comment
There was a problem hiding this comment.
PR #474 审查报告 — hotplex-ai 三维度自动审查
裁决: APPROVE
代码质量: PASS
- DRY/SOLID/命名/错误处理/风格均通过
buildQuestionElements纯函数提取,消除 sendQuestionRequest 内联重复- WARN (低):
buildQuestionElementsvsbuildQuestionFallbackText的 header 默认值和 option 格式化存在概念重复
非功能性: PASS
- 性能: strings.Builder + 预分配 slice,无 DB 查询/锁竞争
- 安全:
copy_text按钮为纯客户端操作,无 XSS/SSRF 向量。Worker 数据经 JSON encoder 转义 - 并发: 新代码为纯函数无共享状态,无 goroutine/channel/mutex 引入
集成与防腐: PASS
- 文档: 直接变更的 admin-api.md 与代码一致(cron 路由、health 认证豁免)
- 测试: 7 个子测试覆盖正常/边界场景,t.Parallel + testify/require
- API 兼容性: 无破坏性变更,新函数均为 unexported
- 依赖: 零新增依赖
非阻塞性建议
docs/specs/AI-Native-Cronjob-Spec.md等 3 个文档仍有旧/api/cron/路径,建议后续批量更新buildQuestionElements按钮文本未调用SanitizeText()(与现有buildInteractionCard模式一致,但与文本消息处理不一致)events.Question.MultiSelect字段被静默忽略(新旧代码均如此)
…x docs paths - buildQuestionElements: call SanitizeText() on all user-facing text (header, question, label, description) to match text message pattern - MultiSelect: show "(可多选)" in card, dynamic footer hint, fallback text multi-select prompt — previously silently ignored - Docs: /api/cron/ → /admin/cron/ in AI-Native-Cronjob-Spec and Turns-Materialized-Table-Spec to match actual routes.go Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
hotplex-ai
previously approved these changes
May 22, 2026
Owner
hotplex-ai
left a comment
There was a problem hiding this comment.
三维度审查报告
代码质量: PASS (8.5/10)
- DRY:
buildV1Card与buildCard分离合理,V1/V2 差异明确 - SOLID:
buildQuestionElements/questionFooterHint/buildV1Card职责分离清晰 - 所有用户输入经
messaging.SanitizeText()清洗 - 错误处理
%w包装规范,卡片发送失败有 text fallback
非功能性(安全+性能+并发): PASS (9/10)
- 安全:
copy_text按钮无服务端回调,天然无注入风险;owner 验证防跨用户响应 - 性能: button slice 预分配,
strings.Builder使用合理 - 并发: 所有新增函数为纯函数,无共享可变状态,线程安全
集成与防腐: PASS (8.5/10)
- 文档与代码行为一致(feishu-integration.md、admin-api.md)
- 测试覆盖充分(7 个子测试 + round-trip)
- V1/V2 卡片隔离正确,无向后兼容问题
- 无新增外部依赖
WARN 项(建议后续处理):
buildQuestionFallbackText未调用SanitizeText(预存在问题,本 PR 扩大了不一致)questionFooterHint()MultiSelect 路径缺少直接测试SanitizeText调用存在冗余(3N vs 2N),可预计算一次- 测试风格与既有 table-driven 模式不完全一致
结论:代码质量高,安全设计合理(copy_text 无回调),变更范围可控。WARN 项均为低优先级改进,不阻塞合并。
…t, table-driven tests - Pre-compute sanitized options slice in buildQuestionElements (2N vs 3N) - Add SanitizeText calls to buildQuestionFallbackText (was missing) - Add TestQuestionFooterHint table-driven test (4 cases: nil/single/multi/mixed) - Convert multi_select subtests to table-driven style matching project conventions Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
copy_text一键复制选项buildV1Card结构错误(body包装 → 根级elements,符合 JSON 1.0 规范)Changes
代码 (3 files):
card_template.go— 新增buildV1Card(JSON 1.0) +buildQuestionElementsinteraction.go—sendQuestionRequest改用 v1 card buildercard_template_test.go— 新增TestBuildV1Card+TestBuildQuestionElements覆盖文档 (3 files, from #475):
docs/reference/admin-api.md— admin API cron paths, restart endpointdocs/tutorials/feishu-integration.md— CardKit v2 交互按钮说明docs/explanation/security-model.md— 安全模型更新Closes #475
🤖 Generated with Claude Code